<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>修改角色</title>
	<meta name="description" content="这是一个 index 页面">
	<meta name="keywords" content="index">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="renderer" content="webkit">
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="icon" type="image/png" href="../assets/i/favicon.png">
	<link rel="apple-touch-icon-precomposed" href="../assets/i/app-icon72x72@2x.png">
	<meta name="apple-mobile-web-app-title" content="Amaze UI" />
	<link rel="stylesheet" href="../assets/css/amazeui.min.css" />
	<link rel="stylesheet" href="../assets/css/amazeui.datatables.min.css" />
	<link rel="stylesheet" href="../assets/css/bootstrap.min.css">
	<link rel="stylesheet" href="../assets/css/app.css">
	<link rel="stylesheet" href="../assets/css/gb_my.css">
	<link rel="stylesheet" href="../assets/css/font-awesome.css">
	<link rel="stylesheet" href="../assets/css/bootstrap-reset.css">
</head>
<body data-type="chart">
	<div class="am-g tpl-g">
		<!--头部-->
		<nav class="navbar navbar-default top-navbar">
			<div class="navbar-header">
				<a class="navbar-brand waves-effect waves-dark" href="javascript:;">
					<img src="../assets/img/logo.png" alt="">
					<strong>轻课网考试系统</strong>
				</a>
				<div id="sideNav" href="">
					<i class="mulv QK QK-mulu"></i>
				</div>
			</div>

			<ul class="nav navbar-top-links navbar-right aaa">
				<li>
					<a id="down_" class="sign-out dropdown-button waves-effect waves-dark" href="javascript:;">
						<span class="am-icon-sign-out"></span> 退出
					</a>
				</li>
				<li>
					<a class="dropdown-button waves-effect waves-dark" href="javascript:;"><b>欢迎你, <span class="userName"></span> </b></a>
				</li>
			</ul>
		</nav>
		<!--导航栏-->
		<nav class="navbar-default navbar-side">
			<div class="sidebar-collapse">
				<!--用户头像-->
				<div class="tpl-sidebar-user-panel">
					<div class="tpl-user-panel-slide-toggleable">
						<div class="tpl-user-panel-profile-picture">
							<img src="../assets/img/user04.png" alt="">
						</div>
					</div>
				</div>
				<dl class="list_dl">
					<dt class="list_dt">
						<a href="../index.html">
							<span class="QK1 start_before"></span>
							<p>首页</p>
						</a>
					</dt>
					<dt class="list_dt">
						<span class="QK1 topic_before"></span>
						<p>题库管理</p>
						<i class="QK1 list_dt_icon"></i>
					</dt>
					<dd class="list_dd">
						<ul>
							<li class="list_li">
								<a href="../questiondb/questiondb.html">管理题库</a>
							</li>
							<li class="list_li">
								<a href="../question/question.html">管理试题</a>
							</li>
						</ul>
					</dd>
					<dt class="list_dt">
						<span class="QK1 paper_before"></span>
						<p>试卷管理</p>
						<i class="QK1 list_dt_icon"></i>
					</dt>
					<dd class="list_dd">
						<ul>
							<li class="list_li">
								<a href="../paper/addpaper.html">创建试卷</a>
							</li>
							<li class="list_li">
								<a href="../paper/paper.html">管理试卷</a>
							</li>
						</ul>
					</dd>
					<dt id="open" class="list_dt">
						<span class="QK1 system_before"></span>
						<p>系统管理</p>
						<i class="QK1 list_dt_icon"></i>
					</dt>
					<dd class="list_dd" style="display: block">
						<ul>
							<li class="list_li">
								<a href="../system.html">系统管理</a>
							</li>
							<li class="list_li">
								<a href="../admin/admin.html">管理员</a>
							</li>
							<li class="list_li" id="style_li_a">
								<a href="../adminroles/adminroles.html">角色管理</a>
							</li>
						</ul>
					</dd>
					<dt class="list_dt">
						<span class="QK1 user_before"></span>
						<p>用户管理</p>
						<i class="QK1 list_dt_icon"></i>
					</dt>
					<dd class="list_dd">
						<ul>
							<li class="list_li">
								<a href="../user/user.html">管理用户</a>
							</li>
							<li class="list_li">
								<a href="../user/usergroup.html">用户分组</a>
							</li>
						</ul>
					</dd>
					<dt class="list_dt">
						<span class="QK1 user_before"></span>
						<p>知识点模块</p>
						<i class="QK1 list_dt_icon"></i>
					</dt>
					<dd class="list_dd">
						<ul>
							<li class="list_li">
								<a href="../KnowledgePoint/KnowledgeBlock.html">管理知识点</a>
							</li>
						</ul>
					</dd>
				</dl>
			</div>
		</nav>
		<!-- 内容区域 -->
		<div id="page-wrapper">
			<div class="row">
				<div class="col-lg-12">
					<section class="panel">
						<header class="panel-heading">
							<span class="label label-primary">增加角色</span>
							<button type="button" class="btn btn-success btn-sm add_clazz btn_my" id="back">
								<span class="QK1 QK-fanhui1"></span>&nbsp;&nbsp;返回
							</button>
						</header>
						<div class="panel-body">
							<table class="table table-bordered table-striped table-condensed table_question" width="100%" align="center">
								<tbody id="wraper" class="roles-add">
								<tr>
									<td class="thx">角色名称</td>
									<td><input class="validate[required] txt" maxlength="20" name="rolename" type="text"> </td>
								</tr>
								<tr>
									<td class="thx">角色备注</td>
									<td><input class="txt" name="remark" maxlength="20" type="text"> </td>
								</tr>
								<tr>
									<td class="thx">角色权限</td>
									<td>
										<div class="flex_div">
											<label><input name="roleprivelege" class="ptitle" value="MAN_DB"  type="checkbox">题库管理</label>

											<label><input name="roleprivelege" value="DB_ADD"  class="ptitlechild" type="checkbox">创建题库</label>

											<label><input name="roleprivelege" value="DB_MODI" class="ptitlechild" type="checkbox">修改题库</label>

											<label><input name="roleprivelege" value="DB_DELETE" class="ptitlechild" type="checkbox">删除题库</label>

											<label><input name="roleprivelege" value="QUESTION_ADD" class="ptitlechild" type="checkbox">创建试题</label>

											<label><input name="roleprivelege" value="QUESTION_MODI" class="ptitlechild" type="checkbox">修改试题</label>

											<label><input name="roleprivelege" value="QUESTION_DELETE" class="ptitlechild" type="checkbox">删除试题</label>
										</div>
										<div class="flex_div">
											<label><input name="roleprivelege" class="ptitle"  value="MAN_PAPER" type="checkbox">试卷管理</label>

											<label><input name="roleprivelege" value="PAPER_ADD" class="ptitlechild" type="checkbox">创建试卷</label>

											<label><input name="roleprivelege" value="PAPER_MODI" class="ptitlechild" type="checkbox">修改试卷</label>

											<label><input name="roleprivelege" value="PAPER_DELETE" class="ptitlechild" type="checkbox">删除试卷</label>

											<label><input name="roleprivelege" value="PAPER_CONFIG" class="ptitlechild" type="checkbox">配置试卷</label>

											<label><input name="roleprivelege" value="EXMA_DETAIL" class="ptitlechild" type="checkbox">查看考试明细</label>

											<label><input name="roleprivelege" value="EXAM_DETAIL_DELETE" class="ptitlechild" type="checkbox">删除考试明细</label>
										</div>
										<div class="flex_div">
											<label><input name="roleprivelege" class="ptitle" value="MAN_EXAM"  type="checkbox">考试管理</label>

											<label><input name="roleprivelege" value="EXAM_MO" class="ptitlechild" type="checkbox">考试监控</label>

											<label><input name="roleprivelege" value="EXAM_FP" class="ptitlechild" type="checkbox">强制收卷</label>
										</div>
										<div class="flex_div">
											<label><input name="roleprivelege" class="ptitle" value="MAN_NEWS"  type="checkbox">新闻公告</label>

											<label><input name="roleprivelege" value="NEWS_ADD" class="ptitlechild" type="checkbox">发布新闻</label>

											<label><input name="roleprivelege" value="NEWS_MODI" class="ptitlechild" type="checkbox">修改新闻</label>

											<label><input name="roleprivelege" value="NEWS_DELETE" class="ptitlechild" type="checkbox">删除新闻</label>

											<label><input name="roleprivelege" value="NEWSTYPE_ADD" class="ptitlechild" type="checkbox">创建分类</label>

											<label><input name="roleprivelege" value="NEWSTYPE_MODI" class="ptitlechild" type="checkbox">管理分类</label>

											<label><input name="roleprivelege" value="NEWSTYPE_DELETE" class="ptitlechild"  type="checkbox">删除分类</label>
										</div>
										<div class="flex_div">
											<label><input name="roleprivelege" class="ptitle" value="MAN_USER"  type="checkbox">用户管理</label>

											<label><input name="roleprivelege" value="USER_ADD" class="ptitlechild" type="checkbox">增加用户</label>

											<label><input name="roleprivelege" value="USER_MODI" class="ptitlechild" type="checkbox">修改用户资料</label>

											<label><input name="roleprivelege" value="USER_DELETE" class="ptitlechild" type="checkbox">删除用户</label>

											<label><input name="roleprivelege" value="USER_GROUP_ADD" class="ptitlechild" type="checkbox">创建用户分组</label>

											<label><input name="roleprivelege" value="USER_GROUP_MODI" class="ptitlechild" type="checkbox">修改用户分组</label>

											<label><input name="roleprivelege" value="USER_GROUP_DELETE" class="ptitlechild" type="checkbox">删除用户分组</label>

											<label><input name="roleprivelege" value="USER_BATCHUP" class="ptitlechild" type="checkbox">批量导入用户</label>

											<label><input name="roleprivelege" value="USER_BATCHOP" class="ptitlechild" type="checkbox">批量修改用户资料</label>
										</div>
										<div class="flex_div">
											<label><input name="roleprivelege" class="ptitle" value="MAN_SYSTEM"  type="checkbox">系统管理</label>

											<label><input name="roleprivelege" value="SYS_CONFIG" class="ptitlechild" type="checkbox">系统设置</label>

											<label><input name="roleprivelege" value="SYS_USERINFO" class="ptitlechild"  type="checkbox">个人资料修改</label>

											<label><input name="roleprivelege" value="ADMIN_ADD" class="ptitlechild" type="checkbox">增加管理员</label>

											<label><input name="roleprivelege" value="ADMIN_ADD" class="ptitlechild" type="checkbox">增加管理员</label>

											<label><input name="roleprivelege" value="ADMIN_MODI" class="ptitlechild" type="checkbox">修改管理员</label>

											<label><input name="roleprivelege" value="ADMIN_DELETE" class="ptitlechild" type="checkbox">删除管理员</label>

											<label><input name="roleprivelege" value="ROLE_ADD" class="ptitlechild" type="checkbox">创建角色</label>

											<label><input name="roleprivelege" value="ROLE_MODI" class="ptitlechild" type="checkbox">修改角色</label>

											<label><input name="roleprivelege" value="ROLE_DELETE" class="ptitlechild" type="checkbox">删除角色</label>
										</div>
										<div class="flex_div">
											<label><input name="roleprivelege" class="ptitle" value="MAN_ANALYSIS"  type="checkbox">分析系统</label>

											<label><input name="roleprivelege" value="ANA_CJ" class="ptitlechild" type="checkbox">成绩分布</label>

											<label><input name="roleprivelege" value="ANA_SJ" class="ptitlechild" type="checkbox">试卷分析</label>

											<label><input name="roleprivelege" value="ANA_KS" class="ptitlechild" type="checkbox">考试分析</label>
										</div>
										<div class="flex_div">
											<label><input name="roleprivelege" class="ptitle" value="MAN_OTHERS"  type="checkbox">其他权限</label>

											<label><input name="roleprivelege" value="SU_ADMIN" class="ptitlechild" type="checkbox">超级管理员权限</label>
										</div>
										<div class="flex_div">
											<label><input name="roleprivelege" class="ptitle" value="MAN_PLUS" type="checkbox">插件管理</label>

											<label><input name="roleprivelege" value="PLUS_ADD" class="ptitlechild" type="checkbox">增加插件</label>

											<label><input name="roleprivelege" value="PLUS_MODI" class="ptitlechild" type="checkbox">修改插件</label>

											<label><input name="roleprivelege" value="PLUS_DELETE" class="ptitlechild" type="checkbox">删除插件</label>
										</div>
										<div class="flex_div">
											<label><input name="roleprivelege" class="ptitle" value="MAN_LOG"  type="checkbox">系统日志</label>

											<label><input name="roleprivelege" value="LOG_VIEW" class="ptitlechild" type="checkbox">系统日志查看</label>
										</div>
									</td>
								</tr>
								<tr>
									<td class="thx">操作</td>
									<td><label><input name="mycheck" id="mycheck"  type="checkbox"> 全/反选</label></td>
								</tr>
								</tbody>
							</table>
							<div class="flex_button">
								<input value=" 提 交 " class="btn submit_button" type="button" id="btnsubmit">
								<input value=" 重 置 " class="btn submit_button" type="reset" id="reset_button">
							</div>
						</div>
					</section>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
<script src="../assets/js/jquery.min.js"></script>
<script src="../assets/js/theme.js"></script>
<script src="../assets/js/JCheck.js"></script>
<script type="text/javascript" src="../assets/js/jquery.cookie.js"></script>
<script src="https://img.hcharts.cn/highcharts/highcharts.js"></script>
<script src="https://img.hcharts.cn/highcharts/modules/data.js"></script>
<script src="https://img.hcharts.cn/highcharts/modules/drilldown.js"></script>
<script src="https://img.hcharts.cn/highcharts-plugins/highcharts-zh_CN.js"></script>
<script src="../assets/js/amazeui.min.js"></script>
<script src="../assets/js/amazeui.datatables.min.js"></script>
<script src="../assets/js/dataTables.responsive.min.js"></script>
<script src="../assets/js/app.js"></script>
<script>
    $("button").click(function() {
        window.location.href = "questiondb.html";
    });
    $("#back").click(function() {
        window.location.href = "adminroles.html";
    });
</script>
<script language="javascript">
    $(document).on('click', '.ptitle', function() {
        var is_me_checked = $(this).is(':checked');
        console.log(is_me_checked);
        if(is_me_checked) {
            $(this).parent().parent().parent().children("label").children("input").prop("checked", true);
        } else {
            $(this).parent().parent().parent().children("label").children("input").prop("checked", false);
        }
    });

    $(document).on('click', '.ptitlechild', function() {
        var is_me_checked = $(this).is(':checked');
        var b = $(this).parent().siblings().children(".ptitlechild");
        var ischecked = false;
        for(i = 0 ; i < b.length ; i++){
            if($(b[i]).is(':checked') == true){
                ischecked = true ;
            }
        }
        if(is_me_checked) {
            $(this).parent().siblings().children(".ptitle").prop("checked", true);
        }else if(ischecked == false && is_me_checked == false){
            $(this).parent().siblings().children(".ptitle").prop("checked", false);
        }
    });
    //全选全不选
    $(document).on('click', '#mycheck', function() {
        var is_me_checked = $(this).is(':checked');
        if(is_me_checked) {
            $("[name = roleprivelege]:checkbox").prop("checked", true);
        } else {
            $("[name = roleprivelege]:checkbox").prop("checked", false);
        }
    });
    //重置
    $('#reset_button').click(function () {
        $("input[type=checkbox]").prop("checked", false);
    });
    var aid = window.location.search.split("=")[1];
    //请求数据

    $.ajax({
        url: localApi + "/AdminRoles/get",
        type: "get",
        data: {
            apikey: '1',
            id: aid
        },
        success: function(result) {
            var roleprivelege = result.data.roleprivelege.split("#");
			$("input[name='rolename']").val(result.data.rolename);
            $("input[name='remark']").val(result.data.remark);
            $.each(roleprivelege, function(n, item) {
                var items = $("input[name='roleprivelege']");
                for (var i = 0; i < items.length; i++) {
                    if (items[i]['value'] == $.trim(item)) {
                        console.log(items[i]['value']);
                        $("input[value='"+$.trim(item)+"']").prop("checked",true);
                    };
                }
            });
        }
    });

    //修改管理员
    $(document).on('click','#btnsubmit',function(){
        var checkID = [];
        $("input[name='roleprivelege']:checked").each(function(i) {
            if($(this).val() != null){
                checkID[i] = $(this).val();
            }
        });
        console.log(checkID)
        $.ajax({

            url: localApi + "/AdminRoles/update",
            type:"POST",
            data:{
                apikey: '1',
                id:aid,
                rolename:$("input[name='rolename']").val(),
                remark:$("input[name='remark']").val(),
                roleprivelege:checkID
            },
            success:function(result){
                if(result.msg == "success"){
                    window.location.href = "adminroles.html";
                }
            }
        });
    });
</script>
<script>
    $(document).ready(function () {
        $(".list_dt").on("click",function () {
            $('.list_dd').stop();
            $(this).siblings("dt").removeAttr("id");
            if($(this).attr("id")=="open"){
                $(this).removeAttr("id").siblings("dd").slideUp();
            }else{
                $(this).attr("id","open").next().slideDown().siblings("dd").slideUp();
            }
        });
    });
</script>
<script>
    $(document).ready(function () {
        $(".dropdown-button").dropdown();
        $("#sideNav").click(function(){
            if($(this).hasClass('closed')){
                $('.navbar-side').animate({left: '0px'});
                $(this).removeClass('closed');
                $('#page-wrapper').animate({'margin-left' : '260px'});
            }
            else{
                $(this).addClass('closed');
                $('.navbar-side').animate({left: '-260px'});
                $('#page-wrapper').animate({'margin-left' : '0px'});
            }
        });
    });
    $(".dropdown-button").dropdown();
</script>